﻿using System.ComponentModel;

namespace FileTransfer.Model
{
    /// <summary>
    /// 下载控制参数
    /// </summary>
    public class ControlParams
    {
        /// <summary>
        /// 运行模式 0 单线程 1 多线程 2 区块
        /// </summary>
        public int RunType { get; set; } = 0;
        /// <summary>
        /// 最大执行任务数量
        /// </summary>
        public int MaxTaskNum { get; set; } = 2;
        /// <summary>
        /// 下载线程数量
        /// </summary>
        public int RunThreadCount { get; set; } = 1;
        /// <summary>
        /// 是否延迟
        /// </summary>
        public bool IsDelay { get; set; } = false;
        /// <summary>
        /// 是否计算MD5
        /// </summary>
        public bool NeedMd5 { get; set; } = true;
        /// <summary>
        /// 单个线程缓存大小
        /// </summary>
        public string SigleTreadCache { get; set; } = "600KB";
        /// <summary>
        /// 缓存大小
        /// </summary>
        public long RunCacheSize
        {
            get
            {
                //默认400k
                long runCacheSize = 1024 * 400;
                if (SigleTreadCache.Equals("100KB"))
                {
                    runCacheSize = 1024 * 100;
                }
                if (SigleTreadCache.Equals("200KB"))
                {
                    runCacheSize = 1024 * 200;
                }
                if (SigleTreadCache.Equals("400KB"))
                {
                    runCacheSize = 1024 * 400;
                }
                if (SigleTreadCache.Equals("600KB"))
                {
                    runCacheSize = 1024 * 600;
                }
                if (SigleTreadCache.Equals("800KB"))
                {
                    runCacheSize = 1024 * 800;
                }
                if (SigleTreadCache.Equals("1M"))
                {
                    runCacheSize = 1024 * 1024 * 1;
                }
                if (SigleTreadCache.Equals("2M"))
                {
                    runCacheSize = 1024 * 1024 * 2;
                }
                if (SigleTreadCache.Equals("3M"))
                {
                    runCacheSize = 1024 * 1024 * 3;
                }
                if (SigleTreadCache.Equals("4M"))
                {
                    runCacheSize = 1024 * 1024 * 4;
                }
                return runCacheSize;
            }

        }
        /// <summary>
        /// 介质格式
        /// </summary>
        [DisplayName("介质格式")]
        public string AllowFormat { get; set; } = string.Empty;
    }
}
